#include "MainMenuScene.h"
#include "GamePlayScene.h";

USING_NS_CC;

Scene* MainMenuScene::createScene()
{
    auto scene = Scene::create();
    auto layer = MainMenuScene::create();
    scene->addChild(layer);
    return scene;
}
bool MainMenuScene::init()
{   
    if ( !Layer::init() ) return false;    
   
	auto uiFromJson = (Layout*)(GUIReader::getInstance()->widgetFromJsonFile("Editor/UI/main_menu.json"));
	this->addChild(uiFromJson, 1);

	auto bttPlayNow = (Button*)(uiFromJson->getChildByName("button_play"));
	bttPlayNow->addTouchEventListener(this, toucheventselector(MainMenuScene::playGame));
    return true;
}

void MainMenuScene::playGame(Ref* pSender, TouchEventType type)
{
	if(type == TouchEventType::TOUCH_EVENT_ENDED)
	{
		Director::getInstance()->replaceScene(GamePlayScene::createScene());
	}
}
